<?php /*a:1:{s:55:"D:\workspace\admin\application\admin\view\ads\edit.html";i:1747297898;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
</head>
<body layadmin-themealias="default">

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body" pad15="">

                    <div class="layui-form" wid100="" lay-filter="">
                        <div class="layui-form-item">
                            <label class="layui-form-label">广告标题</label>
                            <div class="layui-input-block">
                                <input type="text" name="title" value="<?php echo htmlentities($model['title']); ?>" class="layui-input" lay-verify="required">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">显示端</label>
                            <div class="layui-input-block">
                                <input type="radio" value="1" name="equipment" title="PC" lay-filter="equipment"  <?php if($model['equipment'] == '1'): ?>checked<?php endif; ?> />
                                <input type="radio" value="2" name="equipment" title="APP" lay-filter="equipment"  <?php if($model['equipment'] == '2'): ?>checked<?php endif; ?> />
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">广告位置</label>
                            <div class="layui-input-block">
                                <select name="type" lay-verify="required" lay-filter="type_select"  id="typeSelect">
                                    <?php if($model['equipment']==1): ?>
                                    <option value="6" <?php echo $model['type']==6 ? 'selected' : ''; ?>>首页背景图（1920*647）</option>
                                    <option value="10" <?php echo $model['type']==10 ? 'selected' : ''; ?>>直播页轮播图(1620*180)</option>
                                    <option value="11" <?php echo $model['type']==11 ? 'selected' : ''; ?>>顶部导航背景图(1920*68)</option>
                                    <option value="12" <?php echo $model['type']==12 ? 'selected' : ''; ?>>商城首页轮播图(1920*68)</option>
                                    <option value="13" <?php echo $model['type']==13 ? 'selected' : ''; ?>>主播页广告</option>
                                    <option value="14" <?php echo $model['type']==14 ? 'selected' : ''; ?>>直播间弹窗广告</option>
                                    <option value="15" <?php echo $model['type']==15 ? 'selected' : ''; ?>>直播间绑定广告</option>
                                    <?php elseif($model['equipment']==2): ?>
                                    <option value="1" <?php echo $model['type']==1 ? 'selected' : ''; ?>>启动页广告</option>
                                    <option value="2" <?php echo $model['type']==2 ? 'selected' : ''; ?>>首页轮播广告</option>
                                    <option value="12" <?php echo $model['type']==12 ? 'selected' : ''; ?>>商城首页轮播图</option>
                                    <option value="13" <?php echo $model['type']==13 ? 'selected' : ''; ?>>主播页广告</option>
                                    <option value="14" <?php echo $model['type']==14 ? 'selected' : ''; ?>>直播间弹窗广告</option>
                                    <option value="15" <?php echo $model['type']==15 ? 'selected' : ''; ?>>直播间绑定广告</option>
                                    <?php endif; ?>
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">有效期</label>
                            <div class="layui-input-inline">
                                <input type="text" name="start_time" class="layui-input" id="start_date" readonly placeholder="开始日期" lay-verify="required" value="<?php echo htmlentities(date('Y-m-d H:i:s',!is_numeric($model['start_time'])? strtotime($model['start_time']) : $model['start_time'])); ?>">
                            </div>
                            <div class="layui-input-inline" style="width:30px;text-align: center;line-height: 38px">
                                至
                            </div>
                            <div class="layui-input-inline" id="maindiv">
                                <input type="text" name="end_time" class="layui-input" id="end_date" readonly placeholder="结束日期" lay-verify="required" value="<?php echo htmlentities(date('Y-m-d H:i:s',!is_numeric($model['end_time'])? strtotime($model['end_time']) : $model['end_time'])); ?>">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">图片</label>
                            <div class="layui-input-inline">
                                <input name="image_url" lay-verify="required" id="LAY_imgSrc" placeholder="请上传图片或输入地址" value="<?php echo htmlentities($model['image_url']); ?>" class="layui-input" >
                            </div>
                            <div class="layui-input-inline layui-btn-container" style="width: auto;">
                                <button type="button" class="layui-btn layui-btn-primary" id="LAY_imgUpload">
                                    <i class="layui-icon">&#xe67c;</i>上传图片
                                </button>
                                <button class="layui-btn layui-btn-primary" layadmin-event="imgPreview">查看图片</button >
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">绿包用图片</label>
                            <div class="layui-input-inline">
                                <input name="sem_image_url" lay-verify="required" id="LAY_imgSrcSEM" placeholder="请上传图片或输入地址" value="<?php echo htmlentities($model['sem_image_url']); ?>" class="layui-input" >
                            </div>
                            <div class="layui-input-inline layui-btn-container" style="width: auto;">
                                <button type="button" class="layui-btn layui-btn-primary" id="LAY_imgUploadSEM">
                                    <i class="layui-icon">&#xe67c;</i>上传图片
                                </button>
                                <button class="layui-btn layui-btn-primary" layadmin-event="imgPreviewSEM">查看图片</button >
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">跳转类型</label>
                            <div class="layui-input-block">
                                <select name="jump_type" lay-filter="jump_type"  id="jumpType" lay-verify="required">
                                    <option value="1" <?php echo $model['jump_type']==1 ? 'selected' : ''; ?>>跳直播间</option>
                                    <option value="2" <?php echo $model['jump_type']==2 ? 'selected' : ''; ?>>跳网页</option>
                                    <?php if($model['type']==12): ?>
                                    <option value="3" <?php echo $model['jump_type']==3 ? 'selected' : ''; ?>>功能跳转</option>
                                    <?php endif; ?>
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item" id="jumpUrlArea" <?php echo $model['jump_type']==3 ? 'style="display : none"':''; ?>>
                            <label class="layui-form-label">跳转链接</label>
                            <div class="layui-input-block">
                                <input type="text" name="jump_url" value="<?php echo htmlentities($model['jump_url']); ?>" class="layui-input" placeholder="内链直接填路径名，外链加http:// （http://），空链可不填">
                            </div>
                        </div>

                        <div class="layui-form-item" id="storeId" <?php echo $model['jump_type']!=3 ? 'style="display : none"':''; ?>>
                            <label class="layui-form-label">商品ID</label>
                            <div class="layui-input-block">
                                <input type="text" name="store_id" value="<?php echo htmlentities($model['store_id']); ?>"  class="layui-input" placeholder="商城banner输入商品ID，跳转商品详情" onkeyup="clearNoNum(this)">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">关联赛事ID</label>
                            <div class="layui-input-block">
                                <input type="text" name="match_id" placeholder="内跳直播间需关联填写" value="<?php echo htmlentities($model['match_id']); ?>" class="layui-input" lay-verify="">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">赛事类型</label>
                            <div class="layui-input-block">
                                <input type="radio" value="2" name="sport_id" <?php if($model['sport_id'] == '2'): ?>checked<?php endif; ?> title="蓝球" checked />
                                <input type="radio" value="1" name="sport_id" <?php if($model['sport_id'] == '1'): ?>checked<?php endif; ?> title="足球" />
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">排序</label>
                            <div class="layui-input-block">
                                <input type="text" name="sort" placeholder="数值越小越靠前" value="<?php echo htmlentities($model['sort']); ?>" class="layui-input"
                                    lay-verify="">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">是否启用</label>
                            <div class="layui-input-block">
                                <input type="radio" value="1" name="status" title="启用" <?php if($model['status'] == '1'): ?>checked<?php endif; ?> />
                                <input type="radio" value="0" name="status" title="禁用" <?php if($model['status'] == '0'): ?>checked<?php endif; ?> />
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block text-center">
                                <button class="layui-btn" lay-submit="" lay-filter="ads-add">确认保存</button>
                                <button class="layui-btn layui-btn-primary" id="close">取消</button>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>

<script src="/layuiadmin/layui/layui.js"></script>
<script src="/assets/cos-js-sdk-v5/cos-js-sdk-v5.min.js"></script>
<script>
    layui.config({
        base: '/layuiadmin/' //静态资源所在路径
        , version: "<?php echo config('other.ui_version'); ?>"
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form', 'admin', 'ads', 'laydate'], function () {
        var $ = layui.$
            , form = layui.form
            , admin = layui.admin, laydate = layui.laydate;
        var index = parent.layer.getFrameIndex(window.name);

        $(this).removeAttr("lay-key");

        laydate.render({
            elem: '#start_date', //指定元素
            trigger: 'click',
            type:'datetime',
            min: '<?php echo date("Y-m-d H:i:s");?>',
            done: function (value, date, endDate) {
                $("#maindiv").empty();
                $("#maindiv").append('<input type="text" type="text" name="end_time" class="layui-input"  id="end_date" readonly  placeholder="结束日期" />');
                laydate.render({
                    elem: '#end_date', //指定元素
                    trigger: 'click',
                    type:'datetime',
                    min: '<?php echo date("Y-m-d H:i:s");?>',
                });
            },
        });
        laydate.render({
            elem: '#end_date', //指定元素
            trigger: 'click',
            type:'datetime',
            min: '<?php echo date("Y-m-d H:i:s");?>',
        });

        form.on('radio(equipment)', function (data) {
            if (data.value == 1) {
                let html = `<option value="6" <?php echo $model['type']==6 ? 'selected' : ''; ?>>首页背景图（1920*647）</option>
                            <option value="10" <?php echo $model['type']==10 ? 'selected' : ''; ?>> 直播页轮播图(1620*180)</option>
                            <option value="11" <?php echo $model['type']==11 ? 'selected' : ''; ?>>顶部导航背景图(1920*68)</option>
                            <option value="12" <?php echo $model['type']==12 ? 'selected' : ''; ?>>商城首页轮播图(1920*68)</option>
                            <option value="15" <?php echo $model['type']==15 ? 'selected' : ''; ?>>直播间绑定广告</option>
                            `
                $("#typeSelect").html(html);
            }

            if (data.value == 2) {
                let html = `<option value="1" <?php echo $model['type']==1 ? 'selected' : ''; ?>>启动页广告</option>
                            <option value="2" <?php echo $model['type']==2 ? 'selected' : ''; ?>>首页轮播广告</option>
                            <option value="12" <?php echo $model['type']==12 ? 'selected' : ''; ?>>商城首页轮播图(1920*68)</option>
                             <option value="15" <?php echo $model['type']==15 ? 'selected' : ''; ?>>直播间绑定广告</option>
                            `
                $("#typeSelect").html(html);
            }

            form.render();
            // 跳转类型设置
            typeSelectHtml($('#typeSelect').val())
        });

        $('#close').on("click", function () {
            parent.layer.close(index);
        });

        form.on('submit(ads-add)', function (obj) {
            //提交
            admin.req({
                url: '/admin/ads/edit?id=<?php echo htmlentities($model['id']); ?>'
                , data: obj.field
                , success: function (res) {
                    if (res.code == 0) {
                        layer.msg(res.msg, {icon: 1, time: 1500}, function () {
                            parent.window.location.reload();
                        });
                    }
                }
            });
            return false;
        });

        // 广告位置选择
        form.on('select(type_select)', function (data) {
            typeSelectHtml(data.value)
        });

        // 跳转类型选择
        form.on('select(jump_type)', function (data) {
            jumpTypeSlect(data.value)
        });

        function typeSelectHtml(value){
            let html = ` <option value="1">内部跳转</option><option value="2">外部跳转</option>`
            if (value == 12) {
                html += `<option value="3">功能跳转</option>`
            }
            $("#jumpType").html(html);
            jumpTypeSlect(1)
            form.render();
        }

        // 跳转类型 商品和连接显示
        function jumpTypeSlect(value){
            if (value == 3) {
                $('#storeId').show()
                $('#jumpUrlArea').hide()
            } else {
                $('#storeId').hide()
                $('#jumpUrlArea').show()
            }
            // $('#storeId input').val('')
            // $('#jumpUrlArea input').val('')

            form.render();
        }



    });
</script>
</body>
</html>
